yo yo yo~歡迎來到「30天前端設計之旅」的DAY 29!今天我們將學習如何打造更具視覺衝擊力與互動性的網站佈局,包括Pinterest風格的卡片版面、摺疊式選單,以及更具動感的輪播版面。這些設計元素能夠豐富網站的視覺效果,並提升用戶的交互體驗。
D-29的學習目標:
<div class="grid-container">
<div class="grid-item">卡片 1</div>
<div class="grid-item">卡片 2</div>
<div class="grid-item">卡片 3</div>
<div class="grid-item">卡片 4</div>
<div class="grid-item">卡片 5</div>
</div>
.grid-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
}
.grid-item {
background-color: #f4f4f4;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
<div class="accordion">
<div class="accordion-item">
<button class="accordion-button">選單項目 1</button>
<div class="accordion-content">
<p>這是選單項目 1 的內容。</p>
</div>
</div>
<div class="accordion-item">
<button class="accordion-button">選單項目 2</button>
<div class="accordion-content">
<p>這是選單項目 2 的內容。</p>
</div>
</div>
</div>
.accordion-button {
background-color: #b8a29c;
border: none;
padding: 15px;
text-align: left;
font-weight: bold;
cursor: pointer;
width: 100%;
outline: none;
}
.accordion-content {
background-color: #f9f9f9;
padding: 15px;
display: none;
}
.accordion-button:focus + .accordion-content {
display: block;
}
<div id="carouselExample" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="image1.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="image2.jpg" class="d-block w-100" alt="...">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExample" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
</a>
<a class="carousel-control-next" href="#carouselExample" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
</a>
</div>
.carousel-inner img {
border-radius: 10px;
}